<?php
namespace app\admin\controller;
use think\Db;
class System extends Base{
    //表单设置
    public function enclosure(){
        if(request()->isGet()){
            $param = input('get.');
            $data=Db::name('system')->where('id',1)->find();
            $this->assign('data',$data);
            return $this->fetch();
        }elseif(request()->isPost()){
            $param = input('post.');
            $data['file_state']=$param['file_state'];
            $data['accesskey']=$param['accesskey'];
            $data['secretkey']=$param['secretkey'];
            $data['bucket']=$param['bucket'];
            $data['url']=$param['url'];
            $data['uptime'] =time();
            $res= Db::name('system')->where(array('id'=>$param['id']))->update($data);
            if($res){
                return json(['code' => 200,'msg' => '更新成功']);
            }else{
                return json(['code' => 500,'msg' => '失败']);
            }
        }
    }
}
